﻿@model Telecom.Data.VNPT_SITE

@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestmADVTPNSITE"
    };
}

<script type="text/javascript">

    function opBeginProcess_loading_window_submit_laptb() {
        $("#ContentwindowFunction_vnpt_site_lap_tb").mask("Dữ liệu đang xử lý");
    }

    function completedAjaxRequestmADVTPNSITE(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {

            try
            {
                if ($("#loaivnptsite_cap_quang").val() == "daugan") {

                    $("#vnptSite_Dau_Gan").combogrid({ url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL?toql=" + $("#TOQL_cap_quang_hidden").val() + "&donvi=" + $("#DONVIQL_cap_quang_hidden").val() });
                    $("#vnptSite_Dau_Gan").combogrid('setValue', parseInt($("#SITEID_ADDVNPTSITE").val()));
                    $("#vnpt_dau_gan_cap_quan_hidden_ma_check").val($("#MASITE_ADD_CAPQUANG").val());

                    //var stringVNPTDauXa = "";

                    //if ($("#vnpt_dau_xa_cap_quan_hidden_ma_check").val() != "") {

                    //    stringVNPTDauXa = $("#vnpt_dau_xa_cap_quan_hidden_ma_check").val().split('.')[1];

                    //}

                    //var StringvnptDauGan = $("#MASITE_ADD_CAPQUANG").val().split('.');

                    //$("#MA_CAP_QUANG").val("C." + StringvnptDauGan[1] + "-" + stringVNPTDauXa);
                    //$("#TEN_CAP_QUANG").val("C." + StringvnptDauGan[1] + "-" + stringVNPTDauXa);


                }
                else {

                    $("#vnptSite_Dau_xa").combogrid({ url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL?toql=" + $("#TOQL_cap_quang_hidden").val() + "&donvi=" + $("#DONVIQL_cap_quang_hidden").val() });
                    $("#vnptSite_Dau_xa").combogrid('setValue', parseInt($("#SITEID_ADDVNPTSITE").val()));
                    $("#vnpt_dau_xa_cap_quan_hidden_ma_check").val($("#MASITE_ADD_CAPQUANG").val());

                    //var StringvnptDauXa = $("#MASITE_ADD_CAPQUANG").val().split('.');
                    //var stringVNPTDauGan = "";
                    //if ($("#vnpt_dau_gan_cap_quan_hidden_ma_check").val() != "") {
                    //    stringVNPTDauGan = $("#vnpt_dau_gan_cap_quan_hidden_ma_check").val().split('.')[1];
                    //}


                    //$("#MA_CAP_QUANG").val("C." + stringVNPTDauGan + "-" + StringvnptDauXa[1]);
                    //$("#TEN_CAP_QUANG").val("C." + stringVNPTDauGan + "-" + StringvnptDauXa[1]);

                }

            } catch (ex) { }

            close_window_elements('window_add_vnpt_site_cap_quang');


        } else {

            $("#ContentwindowFunction_vnpt_site_lap_tb").unmask();
            confirmOptionNormal(returnObj.Message);
        }

        return false;

    }

     $(document).ready(function () {


         $("#COM_LOAISITE_ADDVTSITE").combobox({
             url: _nameSubDomain + "/Vnpt_Site/listJsonIntoCateTree",
                valueField: "MA",
                textField: "TEN",
                onSelect: function (row) {
                    $("#LOAISITE_ADDVNPTSITE").val(row.MA);
                }
            
            });
            

         $("#COM_DONVIQL_ADDVTSITE").combobox({

             url: _nameSubDomain + "/Donvi_ToQL/Get_DonVi_To_OnJson_InsertText",
             valueField: "id",
             textField: "text",
             onSelect: function (row) {

                 $("#DONVIQL_ADDVNPTSITE").val(row.id);
                 $("#COM_TOQL_ADDVTSITE").combobox({ url: _nameSubDomain + "/Donvi_ToQL/Get_ToAL_To_OnJson_InsertText?ma=" + row.id });
                 $("#TOQL_ADDVNPTSITE").val("");

             }

         });

         $("#COM_TOQL_ADDVTSITE").combobox({

             url: _nameSubDomain + "/Donvi_ToQL/Get_ToAL_To_OnJson_InsertText?ma=@Model.DONVIQL",
             valueField: "MA",
             textField: "TEN",
             onSelect: function (row) {

                 $("#TOQL_ADDVNPTSITE").val(row.MA);
                 $("#COM_QUANHUYEN_ADDVTSITE").combobox({ url: _nameSubDomain + "/Vnpt_Site/ListQuanHuyenbyTo?toql=" + row.MA });
                 setTimeout(function () {

                     var entity = getQHFirstByTo(row.MA);
                     $("#COM_QUANHUYEN_ADDVTSITE").combobox('setValue', entity.MA_QUAN);
                     $("#COM_PHUONGXA_ADDVTSITE").combobox({ url: _nameSubDomain + "/Vnpt_Site/ListPhuongXa?quanhuyenId=" + entity.MA_QUAN + "&toql=" + row.MA });
                     $("#QUANHUYEN_ADDVNPTSITE").val(entity.MA_QUAN);
                     var entityPX = getList_PX_First_By_Quan_Huyen(entity.MA_QUAN, row.MA);
                     $("#COM_PHUONGXA_ADDVTSITE").combobox('setValue', entity.MA_PHUONG);


                 }, 100);


             },

         });



         $("#COM_QUANHUYEN_ADDVTSITE").combobox({

             url: _nameSubDomain + "/Vnpt_Site/ListQuanHuyenbyTo?toql=@Model.TOQL",
             valueField: "MA_QUAN",
             textField: "TEN_QUAN",
             onSelect: function (row) {

                 $("#QUANHUYEN_ADDVNPTSITE").val(row.MA_QUAN);
                 $("#COM_PHUONGXA_ADDVTSITE").combobox({ url: _nameSubDomain + "/Vnpt_Site/ListPhuongXa?quanhuyenId=" + row.MA_QUAN + "&toql=" + $("#TOQL_ADDVNPTSITE").val() });
                 $("#PHUONGXA_ADDVNPTSITE").val("");

             }

         });

         $("#COM_PHUONGXA_ADDVTSITE").combobox({

             url: _nameSubDomain + "/Vnpt_Site/ListPhuongXa?quanhuyenId=@Model.QUANHUYEN" + "&toql=@Model.TOQL", 
             valueField: "MA_PHUONG",
             textField: "TEN_PHUONG",
             onSelect: function (row) {
                 $("#PHUONGXA_ADDVNPTSITE").val(row.MA_PHUONG);
             },

         });


      });
        

</script>

@using (Ajax.BeginForm("UPVNPTSITE_MAPS", "Vnpt_Site", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    @Html.HiddenFor(model => model.SITEID, new { id = "SITEID_ADDVNPTSITE" })
    @Html.HiddenFor(model => model.QUANHUYEN, new { id = "QUANHUYEN_ADDVNPTSITE" })
    @Html.HiddenFor(model => model.PHUONGXA, new { id = "PHUONGXA_ADDVNPTSITE" })
    @Html.HiddenFor(model => model.DONVIQL, new { id = "DONVIQL_ADDVNPTSITE" })
    @Html.HiddenFor(model => model.TOQL, new { id = "TOQL_ADDVNPTSITE" })
    @Html.HiddenFor(model => model.LOAISITE, new { id = "LOAISITE_ADDVNPTSITE" })
    
    <input type="hidden" value="@ViewBag.LoaiSiteCapUPDATE" id="loaivnptsite_cap_quang" name="loaivnptsite_cap_quang" />
    <input type="hidden" name="ma_vnpt_site_update_page_MAPS" id="ma_vnpt_site_update_page_MAPS" value="@Model.MA" />
    
    <div id="ContentwindowFunction_vnpt_site_lap_tb" class="ContentwindowFunction_vnpt_site_lap_tb">
       <table class="tableContentWindowFunction">
           <tr>
                <td>
                   Đơn vị QL : 
                </td>
               <td>
                    <input class="easyui-combobox" value="@Model.DONVIQL" style="width:450px; height:27px" id="COM_DONVIQL_ADDVTSITE" name="DONVIQL_ADDVTSITE">
               </td>
           </tr>
           <tr>
                <td>
                   Tổ QL : 
                </td>
               <td>
                    <input class="easyui-combobox" value="@Model.TOQL" style="width:450px; height:27px" id="COM_TOQL_ADDVTSITE" name="TOQL_ADDVTSITE">
               </td>
           </tr>
           <tr>
                <td>
                   Loại site : 
                </td>
               <td>
                    <input class="easyui-combobox" value="ODF" style="width:450px; height:27px" id="COM_LOAISITE_ADDVTSITE" name="LOAISITE_ADDVTSITE">
               </td>
           </tr>
           <tr>
                <td>
                   Mã : 
                </td>
               <td>
                    @Html.TextBoxFor(model => model.MA, new { id ="MASITE_ADD_CAPQUANG", @class = "input_table_function maTable"})
               </td>
           </tr>
           <tr>
                <td>
                   Tên : 
                </td>
               <td>
                    @Html.TextBoxFor(model => model.TEN, new { id ="TENSITE_ADD_CAPQUANG", @class = "input_table_function"})
               </td>
           </tr>
           <tr>
                <td>
                   Địa chỉ : 
                </td>
               <td>
                    @Html.TextBoxFor(model => model.DIACHI, new { @class = "input_table_function"})
               </td>
           </tr>
           <tr>
                <td>
                   Quận/Huyện : 
                </td>
               <td>
                    <input class="easyui-combobox" value="@Model.QUANHUYEN" style="width:450px; height:27px" id="COM_QUANHUYEN_ADDVTSITE" name="QUANHUYEN_ADDVTSITE">
               </td>
           </tr>
           <tr>
                <td>
                   Phường/Xã : 
                </td>
               <td>
                    <input class="easyui-combobox" value="@Model.PHUONGXA" style="width:450px; height:27px" id="COM_PHUONGXA_ADDVTSITE" name="PHUONGXA_ADDVTSITE">
               </td>
           </tr>
           <tr>
                <td>
                   Long: 
                </td>
               <td>
                    @Html.TextBoxFor(model => model.X, new { @class = "input_table_function"})
               </td>
           </tr>
           <tr>
                <td>
                   Lat : 
                </td>
               <td>
                    @Html.TextBoxFor(model => model.Y, new { @class = "input_table_function"})
               </td>
           </tr>
       </table>
        <div style="height:30px"></div>
        <div class="footer_submit" style="margin-top: 10px; text-align: center">
            <button type="submit" onclick="return opBeginProcess_loading_window_submit_laptb(); ">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Cập nhật VNPT SITE</span><span class="l-btn-icon icon-add">&nbsp;</span></span>    
            </button>
            <button type="button" onclick="return close_window_elements('window_add_vnpt_site_cap_quang');" >
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Hủy bỏ</span><span class="l-btn-icon icon-remove">&nbsp;</span></span></button>
        </div>
    </div>
    

}